<template>
  <el-form ref="form2" :model="formData" :validate-on-rule-change=false label-width="120px">
    <el-form-item v-if="xlr1 !== '2'" :label="label1" prop="shr1" :rules="[
      { required: true, message: '请输入', trigger: 'blur' },
    ]">
      <el-select v-model="formData.shr1" filterable allow-create default-first-option placeholder="请选择">
        <el-option v-for="({ sjxdm, sjxmc }, index) in xlsj1" :key="index" :label="sjxmc" :value="sjxdm">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item v-if="xlr2 !== '2'" :label="label2" prop="shr2" :rules="[
      { required: true, message: '请输入', trigger: 'blur' },
    ]">
      <el-select v-model="formData.shr2" filterable allow-create default-first-option placeholder="请选择">
        <el-option v-for="({ sjxdm, sjxmc }, index) in xlsj2" :key="index" :label="sjxmc" :value="sjxdm">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item v-if="spxx !== '2'" label="审批" prop="spjg" :rules="[
      { required: true, message: '请输入', trigger: 'blur' },
    ]">
      <el-select v-model="formData.spjg" filterable allow-create default-first-option placeholder="请选择">
        <el-option v-for="({ sjxdm, sjxmc }) in xlsjzdy" :key="sjxdm" :label="sjxmc" :value="sjxdm">
        </el-option>
      </el-select>
    </el-form-item>
    <el-form-item v-if="xpyjd !== '2'" label="审核意见" prop="shyj" :rules="[
      { required: true, message: '请输入', trigger: 'blur' },
    ]">
      <el-input v-model="formData.shyj" type="textarea" :rows="4" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="doSubmit1"> 提交 </el-button>
      <el-button class="cancelBtn" @click="doClose1"> 关 闭 </el-button>
    </el-form-item>
  </el-form>

</template>
<script lang="ts">
import Vue from 'vue'

export default Vue.extend({
  props: {
    label1: {
      type: String,
      default: '审核',
    },
    label2: {
      type: String,
      default: '审核1',
    },
    xlurl: {
      type: String,
      default: 'sp',
    },
    jklj: {
      type: String,
      default: 'sp',
    },


    xlr1: {
      type: String,
      default: '2',
    },
    xlr2: {
      type: String,
      default: '2',
    },
    spxx: {
      type: String,
      default: '2',
    },
    xpyjd: {
      type: String,
      default: '2',
    },

  },
  name: 'Sbgl-yqsbwx-wxsq',
  components: {
  },
  data() {
    return {
      xlsj1: [], // 选择器数据
      xlsj2: [], // 选择器数据
      xlsjzdy: [
        { sjxdm: '驳回', sjxmc: '驳回' },
        { sjxdm: '通过', sjxmc: '通过' },
      ],//查询选择器 下拉数据
      formData: {
        "shr1": "",
        "shr2": "",
        "spjg": "",
        "shyj": "",
      }, //录入Form数据
    }
  },
  computed: {
  },
  watch: {
    xlr1: {
      handler(newVal, oldVal) {
        this.getxlsj1();
      },
      // deep: true,
    },
    xlr2: {
      handler(newVal, oldVal) {
        this.getxlsj1();
      },
      // deep: true,
    },

  },
  mounted() {
    this.getxlsj1();
  },
  methods: {
    resetQuery() {  //查询参数重置按钮事件
      this.formData = {
        "shr1": "",
        "shr2": "",
        "spjg": "",
        "shyj": "",
      }
    },
    getxlsj1() { //获取 选择器数据
      try {
        // const param = {
        //   p_qsrq: this.queryParams.sel_qsrq,
        //   p_jzrq: this.queryParams.sel_jzrq,
        // };
        if (this.xlr1 === '1') {
          this.$getSelectorData(this.xlurl, {}, this.jklj).then((res) => {
            this.xlsj1 = res.success ? res.rows : []
          })
        }
        if (this.xlr2 === '1') {
          this.$getSelectorData(this.xlurl, {}, this.jklj).then((res) => {
            this.xlsj2 = res.success ? res.rows : []
          })
        }
        this.resetQuery();

      } catch (error) {
        console.warn('接口提示', error)
      }
    },
    doClose1() {//处理关闭事件
      this.$emit('gbfun');
      this.resetQuery();
    },
    doSubmit1() {
      this.$refs['form2'].validate((valid) => {
        if (valid) {
          this.$emit('shfun', this.formData);
        }
      });
    },
  },
})
</script>
<style lang="less" scoped>
.app-container {
  height: 100%;
}

::v-deep .el-dialog__body {
  max-height: 60vh;
  overflow-y: auto;
}



::v-deep .el-input.is-disabled .el-input__inner,
::v-deep .el-textarea.is-disabled .el-textarea__inner,
::v-deep .el-radio.is-disabled .el-radio__inner,
::v-deep .el-radio.is-disabled .el-radio__label,
::v-deep .el-checkbox.is-disabled .el-checkbox__inner,
::v-deep .el-checkbox.is-disabled .el-checkbox__label {
  background-color: #f6f6f6 !important;
  /* 示例：改变背景颜色 */
  color: #333 !important;
  /* 示例：改变文字颜色 */
}

::v-deep .el-upload.el-upload--text {
  margin: 0 !important;
}

.mainSearchPanel .page-header-title {
  font-size: 16px;
  color: #409EFF;
  font-weight: bolder;
  display: block;
  margin: 0;
  padding: 0;
  margin: 10px 0;
}

.mainSearchPanel .el-divider--horizontal {
  margin: 0 !important;
  margin-top: 10px;
}
</style>
